package com.imooc.coupon.feign.hystrix;

import com.imooc.coupon.exception.CouponException;
import com.imooc.coupon.feign.SettlementClient;
import com.imooc.coupon.vo.CommonResponse;
import com.imooc.coupon.vo.SettlementInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * <h1>结算微服务熔断策略实现</h1>
 * @Author: crowsjian
 * @Date: 2020/6/20 15:12
 */
@Slf4j
@Component
public class SettlementClientHystrix implements SettlementClient {
    /**
     * <h2>优惠卷计算规则</h2>
     * @param settlementInfo
     * @return
     * @throws CouponException
     */
    @Override
    public CommonResponse<SettlementInfo> conputeRule(SettlementInfo settlementInfo)
            throws CouponException {
        log.error("[eureka-client-coupon-settlement] conputeRule" +
                "request error");
        settlementInfo.setEmploy(false);
        settlementInfo.setCost(-1.0);
        return new CommonResponse<>(-1,
                "[eureka-client-coupon-settlement] request error",
                settlementInfo);
    }
}
